package com.bonana.core.services.impl;

import com.bonana.core.dao.index.IndexProjectMapper;
import com.bonana.core.dao.user.PartnerUserDao;
import com.bonana.core.entity.PartnerUser;
import com.bonana.core.entity.mybatis.IndexProject;
import com.bonana.core.services.PartnerService;
import com.bonana.utils.StringUtils;
import com.github.pagehelper.PageHelper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by xiabin on 16/5/20.
 */
@Service
public class PartnerServiceImpl implements PartnerService {
    private Logger logger = LogManager.getLogger(PartnerServiceImpl.class);
    @Autowired
    PartnerUserDao partnerUserDao;

    @Override
    public int AddPartner(PartnerUser user) {
        logger.info("AddPartner: {}", user.getUsername());
        return partnerUserDao.AddPartner(user);
    }

    @Override
    public int DelPartnerById(int partnerId) {
        logger.info("DelPartnerById: {}", partnerId);
        return partnerUserDao.DelPartner(partnerId);
    }

    @Override
    public int UpdatePartner(PartnerUser user) {
        return partnerUserDao.UpdatePartner(user);
    }

    @Override
    public PartnerUser getPartnerById(int partnerId) {
        return partnerUserDao.queryPartnerById(partnerId);
    }

    @Override
    public List<PartnerUser> getPartner(int pgNum, int pgSize, String query) {
        PageHelper.startPage(pgNum, pgSize);
        List<PartnerUser> list = partnerUserDao.getPartners(query.equals("")?null:query);

        return list;
    }
}
